package com.crm.service.statisticAnalysis.controller;

import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.statisticAnalysis.dtos.CluePageDTO;
import com.crm.service.statisticAnalysis.service.ClueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("/api/v1/statistics/clue")
@Slf4j
@Api(value = "线索统计")
public class ClueController {

    @Autowired
    private ClueService clueService;

    @ApiOperation("线索统计分页")
    @PostMapping("/cluePage")
    private ResponseResult cluePage(@RequestBody CluePageDTO cluePageDTO){
        log.info("线索分页条件查询:{}",cluePageDTO);
        return clueService. cluePage(cluePageDTO);
    }

    @ApiOperation("线索统计折线图")
    @GetMapping("/clue_lineChart")
    private ResponseResult clueLineChart(
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end){
        log.info("线索统计折线图:{},{}",begin,end);
        return clueService.clueLineChart(begin,end);
    }

    @ApiOperation("线索漏斗图")
    @GetMapping("/clue_doughnutChart")
    private ResponseResult clueDoughnutChart(
            @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate begin,
            @DateTimeFormat(pattern = "yyyy-MM-dd")LocalDate end){
        log.info("线索漏斗图:{}{}",begin,end);
        return clueService.clueDoughnutChart(begin,end);
    }


}
